package com.huawei.appmarket.service.usercenter.personal.view.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.store.bean.user.GetPersonalInfoResBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.framework.widget.ClipRoundImageView;
import com.huawei.appmarket.service.usercenter.userinfo.view.widget.UserInfoTextView;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import huawei.widget.HwTextView;
import o.azb;
import o.cgz;
import o.ckt;
import o.der.d;
import o.der.e;
import o.der.f;
import o.der.g;
import o.Logger;
import o.dof;
import o.ekg;
import o.eko;
import o.ekp;
import o.ekr;
import o.ekt;
import o.eld;
import o.elf;
import o.ell;
import o.eme;
import o.equ;

public class BasePersonalInfoCard extends cgz implements OnClickListener {
    private LinearLayout ʻ;
    private LayoutInflater ʻॱ;
    private ImageView ʼ;
    private TextView ʽ;
    private ClipRoundImageView ˊ;
    private String ˊॱ;
    private RelativeLayout ˋ;
    private UserInfoTextView ˋॱ;
    private ImageView ˎ;
    private RelativeLayout ˏ;
    private TextView ˏॱ;
    private ImageView ͺ;
    private LinearLayout ॱ;
    private TextView ॱˊ;
    private PopupWindow ॱˋ;
    private LinearLayout ॱॱ;
    private eme ॱᐝ;
    private TextView ᐝ;

    static class b implements OnDismissListener {
        b() {
        }

        public void onDismiss() {
            ekg.ॱ().ॱ(false);
        }
    }

    public BasePersonalInfoCard(Context context) {
        super(context);
    }

    protected boolean ˎ() {
        return false;
    }

    protected boolean ˊ() {
        return false;
    }

    public cgz ˏ(View view) {
        ˋ(view);
        ʽ(view);
        ॱˊ();
        return this;
    }

    public void ˏ(CardBean cardBean) {
        ʻ();
        ʽ();
        ᐝ();
        ˏॱ();
        this.ˋॱ.setContentWidth(((azb.ॱ(this.ʼॱ) - (this.ʼॱ.getResources().getDimensionPixelOffset(o.der.b.ॱॱ) * 4)) - this.ʼॱ.getResources().getDimensionPixelOffset(o.der.b.ͺ)) - this.ʼॱ.getResources().getDimensionPixelOffset(o.der.b.ॱᐝ));
        if (ˎ() && ekt.ˎ()) {
            this.ˋॱ.setVisible(true);
        } else {
            this.ˋॱ.setVisible(false);
        }
        this.ˋॱ.setData(this.ॱᐝ);
        ʼ();
    }

    private void ˋ(View view) {
        this.ˏ = (RelativeLayout) view.findViewById(d.ॱᐝ);
        azb.ॱॱ(this.ˏ);
        this.ˋ = (RelativeLayout) view.findViewById(d.ᐝॱ);
        azb.ॱॱ(this.ˋ);
        this.ˎ = (ImageView) view.findViewById(d.ॱˋ);
        this.ॱ = (LinearLayout) view.findViewById(d.ʻॱ);
        this.ʽ = (TextView) view.findViewById(d.ˈ);
        this.ˊ = (ClipRoundImageView) view.findViewById(d.ॱˎ);
        this.ˋॱ = (UserInfoTextView) view.findViewById(d.ᐝʽ);
        this.ॱᐝ = new eme();
        this.ʼ = (ImageView) view.findViewById(d.ˌ);
        this.ᐝ = (TextView) view.findViewById(d.ʾ);
        this.ॱॱ = (LinearLayout) view.findViewById(d.ʿ);
        this.ʻ = (LinearLayout) view.findViewById(d.ˉ);
        this.ͺ = (ImageView) view.findViewById(d.ˊˋ);
        this.ˏॱ = (TextView) view.findViewById(d.ˊᐝ);
        this.ॱˊ = (TextView) view.findViewById(d.ˋˊ);
        ʻ();
    }

    private void ʻ() {
        if (ekt.ˎ()) {
            this.ˏ.setVisibility(8);
            this.ˋ.setVisibility(0);
            this.ॱ.setVisibility(0);
            return;
        }
        this.ˏ.setVisibility(0);
        this.ˋ.setVisibility(8);
        this.ॱ.setVisibility(8);
        if (ˊ()) {
            this.ᐝ.setVisibility(0);
        } else {
            this.ᐝ.setVisibility(8);
        }
    }

    private void ʽ() {
        String ʼ = dof.ʼ(UserSession.getInstance().getHeadUrl());
        if (!ekt.ˎ() || TextUtils.isEmpty(ʼ)) {
            this.ʼ.setImageResource(e.ˉ);
            this.ˊॱ = null;
        } else if (ʼ.equals(this.ˊॱ)) {
            Logger.ˏ("BasePersonalInfoCard", "same url , no need refresh");
        } else {
            equ.ˊ(this.ʼ, ʼ, "head_default_icon");
            this.ˊॱ = ʼ;
        }
    }

    private void ᐝ() {
        Object userName = UserSession.getInstance().getUserName();
        if (ekt.ˎ() && !TextUtils.isEmpty(userName)) {
            this.ॱᐝ.ˊ(userName);
        } else if (UserSession.getInstance().getStatus() == 3) {
            this.ʽ.setText(f.ʽʽ);
        } else {
            this.ʽ.setText(f.ˊʽ);
        }
    }

    private void ʼ() {
        int ॱॱ;
        GetPersonalInfoResBean ˊ = ekg.ॱ().ˊ();
        if (ekt.ˎ()) {
            CharSequence charSequence;
            CharSequence ʼ;
            String str = "——";
            String str2 = "——";
            if (ˊ != null) {
                if (!dof.ˋ(ˊ.ᐝ())) {
                    str = ˊ.ᐝ();
                }
                if (!dof.ˋ(ˊ.ʼ())) {
                    charSequence = str;
                    ʼ = ˊ.ʼ();
                    this.ˏॱ.setText(charSequence);
                    this.ॱˊ.setText(ʼ);
                }
            }
            String str3 = str2;
            Object obj = str;
            Object obj2 = str3;
            this.ˏॱ.setText(charSequence);
            this.ॱˊ.setText(ʼ);
        }
        if (ˊ != null) {
            ॱॱ = ˊ.ॱॱ();
        } else {
            ॱॱ = 0;
        }
        ॱ(ॱॱ == 1, this.ͺ);
        ॱ(ˊ);
        ekr.ॱ(ekp.ॱ, Integer.valueOf(ॱॱ));
    }

    private void ॱ(GetPersonalInfoResBean getPersonalInfoResBean) {
        if (ekg.ॱ().ˋ() && getPersonalInfoResBean != null && getPersonalInfoResBean.ॱ() != null && !dof.ˋ(getPersonalInfoResBean.ॱ().ˋ())) {
            if (this.ʻॱ == null) {
                this.ʻॱ = LayoutInflater.from(this.ʼॱ);
            }
            LinearLayout linearLayout = (LinearLayout) this.ʻॱ.inflate(g.ʿ, null);
            if (linearLayout != null) {
                this.ˏॱ.measure(0, 0);
                int measuredWidth = this.ˏॱ.getMeasuredWidth();
                int measuredHeight = this.ˏॱ.getMeasuredHeight();
                if (this.ॱˋ == null) {
                    this.ॱˋ = new PopupWindow(linearLayout, -2, -2, false);
                }
                this.ॱˋ.showAsDropDown(this.ˏॱ, measuredWidth - 3, (-measuredHeight) - 24, 8388611);
                ((HwTextView) this.ॱˋ.getContentView().findViewById(d.ʼᐝ)).setText(getPersonalInfoResBean.ॱ().ˋ());
                this.ॱˋ.setOutsideTouchable(true);
                this.ॱˋ.setOnDismissListener(new b());
            }
        }
    }

    private void ˏॱ() {
        GetPersonalInfoResBean ˊ = ekg.ॱ().ˊ();
        if (ˊ != null) {
            this.ॱᐝ.ॱ(ˊ.ˊ());
            this.ॱᐝ.ॱ(ˊ.ˎ());
        }
    }

    private void ॱˊ() {
        OnClickListener o_ckt = new ckt(this);
        this.ˏ.setOnClickListener(o_ckt);
        this.ˊ.setOnClickListener(o_ckt);
        this.ˎ.setOnClickListener(o_ckt);
        this.ʼ.setOnClickListener(o_ckt);
        this.ॱॱ.setOnClickListener(o_ckt);
        this.ʻ.setOnClickListener(o_ckt);
        this.ˋॱ.ˎ().setOnClickListener(o_ckt);
    }

    public void onClick(View view) {
        if (view.getId() == d.ॱᐝ || view.getId() == d.ˌ || view.getId() == d.ॱˋ || view.getId() == d.ﹳॱ || view.getId() == d.ॱˎ) {
            if (!UserSession.getInstance().isLoginSuccessful()) {
                this.ˋॱ.setNickName(f.ʽʽ);
            }
            ˋ();
            new ell(ˉ().getContext()).ॱ();
        } else if (view.getId() == d.ʿ) {
            GetPersonalInfoResBean ˊ = ekg.ॱ().ˊ();
            if (ˊ != null) {
                ˊ.ˎ(0);
            }
            ॱ(false, this.ͺ);
            ॱॱ();
            new elf(ˉ().getContext()).ˊ();
        } else if (view.getId() == d.ˉ) {
            ˊॱ();
            new eld(ˉ().getContext()).ˊ();
        }
    }

    protected void ˋ() {
        if (ekt.ˎ()) {
            eko.ˎ(f.ˏˎ, KeyAndValue.NUMBER_01);
        } else {
            eko.ˎ(f.ﾞ, KeyAndValue.NUMBER_01);
        }
    }

    protected void ॱॱ() {
        eko.ˋ(f.ᐝᐝ, KeyAndValue.NUMBER_01);
    }

    private void ˊॱ() {
        eko.ˋ(f.ꜞ, KeyAndValue.NUMBER_01);
    }

    private void ॱ(boolean z, View view) {
        if (z) {
            view.setVisibility(0);
        } else {
            view.setVisibility(8);
        }
    }
}
